package mop.exception;


import mop.model.task.field.Field;
import mop.model.task.field.FieldInterface;

public class IllegalFieldException extends Throwable{
	
	/**
	 * Initializes an IllegalFieldException with given field
	 * 
	 * @param field	Field that gave error
	 * @post		Set the field
	 */
	public IllegalFieldException(FieldInterface field)
	{
		this.field = field;	
	}
	
	/**
	 * Construct IllegalFieldException 
	 * @param field	Field that gave error
	 * @effect call twin constructor with field interface
	 */
	public IllegalFieldException(Field field){
		this(field.getInterface());
	}
	
	/**
	 * Return a error message that can be used by the gui
	 * @return An error message describing the incorrect value
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("The following field was not found ! :");
		sb.append("Identifier: "+field.getId()+" Description: "+field.getDescription());
		
		return sb.toString();
		
	}
	
	 
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The field thats causing the problem
	 */
	private final FieldInterface field;
	

}
